//
// Created by yunnan xu on 2021/6/6.
//

#ifndef ANDROIDGRAPHICSDEMOS_SKINNEDMESHMODEL_H
#define ANDROIDGRAPHICSDEMOS_SKINNEDMESHMODEL_H

#include "MeshModel.h"
#include "Bone.h"
#include <vector>
#include "glm.hpp"

struct BoneVertexData
{
    BoneVertexData(int index, float weight) {bone_index = index; bone_weight = weight;}
    unsigned int bone_index;
    float bone_weight;
};

class SkinnedMeshModel : public MeshModel{

public:

    SkinnedMeshModel(const char *modelPath, std::unordered_set<VertexAttribType> attribList);
    void Update(double elapsed_time, double tot_time);

    float * GetBoneTransformMatrixList();
    int GetBoneNumber();

private:

    std::vector<float> bone_matrix_list;
    int bone_number;
    void TravelBoneHierarchy(aiNode* parent, double time, const glm::mat4x4 & parent_transform);

    std::unordered_map<std::string, int> bone_name_2_index;
    std::vector<glm::mat4x4> bone_matrix;
};


#endif //ANDROIDGRAPHICSDEMOS_SKINNEDMESHMODEL_H
